import 'package:flutter/material.dart';
import '../model/car.dart';
import '../network/http_network.dart';

class AppIndex extends StatefulWidget {
  const AppIndex({super.key});

  @override
  State<AppIndex> createState() => _AppIndexState();
}

class _AppIndexState extends State<AppIndex> {
  @override
  void initState() {
    // TODO: implement initState
    super.initState();

    var resp = HttpManager.manager.get(
        path: 'https://api.shunliandongli.com/v2/front/adpush/updateappcheck').then((value) {
         
            print(value.data);
            print('--------------');

        });
    
  }

  //生成单独的cell
  Widget _itemForrow(BuildContext context, int index) {
    return Container(
        color: Colors.grey[100],
        margin: const EdgeInsets.only(left: 10, right: 10, top: 10, bottom: 0),
        child: Column(
          children: [
            Image.network(data[index].age!),
            Text(
              data[index].name!,
              style: const TextStyle(
                fontSize: 22,
                fontWeight: FontWeight.w400,
                fontFamily: 'PingFang SC',
              ),
            ),
          ],
        ));
  }

  @override
  Widget build(BuildContext context) {
    return Scaffold(
      backgroundColor: Colors.red,
      appBar: AppBar(
        title: const Text("首页"),
      ),
      body: ListView.builder(
        itemCount: data.length,
        itemBuilder: (BuildContext context, int index) {
          return _itemForrow(context, index);
        },
      ),
    );
  }
}

List<Car> data = [
  const Car(
      name: "名字0",
      age:
          "https://inews.gtimg.com/om_bt/OjPq2cnMN_-ivDKjxpCZ2kk_ab8YC5VMnL-0pQ21fUvd4AA/1000"),
  const Car(
      name: "名字1",
      age:
          "https://inews.gtimg.com/om_bt/OjPq2cnMN_-ivDKjxpCZ2kk_ab8YC5VMnL-0pQ21fUvd4AA/1000"),
  const Car(
      name: "名字2",
      age:
          "https://inews.gtimg.com/om_bt/OjPq2cnMN_-ivDKjxpCZ2kk_ab8YC5VMnL-0pQ21fUvd4AA/1000"),
  const Car(
      name: "名字3",
      age:
          "https://inews.gtimg.com/om_bt/OjPq2cnMN_-ivDKjxpCZ2kk_ab8YC5VMnL-0pQ21fUvd4AA/1000"),
  const Car(
      name: "名字4",
      age:
          "https://inews.gtimg.com/om_bt/OjPq2cnMN_-ivDKjxpCZ2kk_ab8YC5VMnL-0pQ21fUvd4AA/1000"),
  const Car(
      name: "名字5",
      age:
          "https://inews.gtimg.com/om_bt/OjPq2cnMN_-ivDKjxpCZ2kk_ab8YC5VMnL-0pQ21fUvd4AA/1000"),
  const Car(
      name: "名字6",
      age:
          "https://inews.gtimg.com/om_bt/OjPq2cnMN_-ivDKjxpCZ2kk_ab8YC5VMnL-0pQ21fUvd4AA/1000"),
  const Car(
      name: "名字7",
      age:
          "https://inews.gtimg.com/om_bt/OjPq2cnMN_-ivDKjxpCZ2kk_ab8YC5VMnL-0pQ21fUvd4AA/1000"),
  const Car(
      name: "名字8",
      age:
          "https://inews.gtimg.com/om_bt/OjPq2cnMN_-ivDKjxpCZ2kk_ab8YC5VMnL-0pQ21fUvd4AA/1000"),
  const Car(
      name: "名字9",
      age:
          "https://inews.gtimg.com/om_bt/OjPq2cnMN_-ivDKjxpCZ2kk_ab8YC5VMnL-0pQ21fUvd4AA/1000"),
];
